﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel;



namespace HAVTKPack
{
   public abstract class Node
   {

       #region 构造函数

       protected Node(string name)
       {
           this._name = name;

           this._desc = name;

           this._position = new Vector(0,0,0);

           this._scale = new Vector(1,1,1);

           this._rotation = new Vector(0,0,0);



           this._filters = new List<Filter>();

       }

       #endregion



       #region 字段属性

       string _name;
       /// <summary>
       /// ID
       /// </summary>
       public string Name
       {
           get { return _name; }
          
       }


       string _desc;


       /// <summary>
       /// 节点描述名称
       /// </summary>
       public string Desc
       {
           get { return _desc; }
           set { _desc = value; }
       }




       protected int groupID;

       protected bool enabled;

       protected Node parent;
       protected Object userData;



       protected List<Filter> _filters;

       /// <summary>
       /// 可供直接渲染的fiter实例
       /// </summary>
       public List<Filter> Filters
       {
           get { return _filters; }
         
       }




      protected Vector _position;
       /// <summary>
       /// 位置
       /// </summary>
       public virtual Vector Position
       {
           get { return _position; }
           set {

               if (this._position!=value)
               {
                   _position = value;

                   this.OnSetPosition();

                   
               }
              
           
           }
       }

 

       protected Vector _scale;
       /// <summary>
       /// 缩放
       /// </summary>
       public  virtual  Vector Scale
       {
           get { return _scale; }
           set {
               if (this._scale !=value )
               {
                   _scale = value;

                   this.OnSetScale();
               }            
           
           }
       }


     


       protected Vector _rotation;
       /// <summary>
       /// 旋转
       /// </summary>
       public  virtual  Vector Rotation
       {
           get { return _rotation; }
           set {
               if (this.Rotation!=value  )
               {
                   _rotation = value;
                   this.OnSetRotation();
               }
              
           }
       }
     





       protected Scene scene;

        public Scene Scene
        {
            get { return scene; }
            set { scene = value; }
        }


       #endregion

       




        #region 公共方法


        /// <summary>
        /// 分发实现底层的调用关系
        /// </summary>
        protected virtual void OnSetPosition()
        {
            //if (this.scene.IsRendering)
            {

            }
        }


        protected virtual void OnSetScale()
        {
            //if (this.scene .IsRendering )
            {

            }

        }



        protected virtual void OnSetRotation()
        {
            //if (this.scene.IsRendering)
            {

            }

        }






        public abstract void Render();


        public abstract void StopRender();
       

       /// <summary>
       /// 初始化所有的属性值
       /// </summary>
        public virtual void InitProp()
        {

        }


        public virtual void ReLoad()
        {

        }


        #endregion


   }
}
